home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / Chip Temmuz 2004.iso / program / antispam / RazorAgent_SDK / razor-agents-sdk-2.03.exe / URI-1.19 / t / roy-test.t < prev    next >
Encoding:
Text File  |  1999-03-19  |  1003 b   |  39 lines

  1. print "1..102\n";
  2.  
  3. if (-d "t") {
  4.    chdir("t") || die "Can't chdir 't': $!";
  5.    # fix all relative library locations
  6.    foreach (@INC) {
  7.       $_ = "../$_" unless m,^/,;
  8.    }
  9. }
  10.  
  11. use URI;
  12. $no = 1;
  13.  
  14. for $i (1..5) {
  15.    my $file = "roytest$i.html";
  16.  
  17.    open(FILE, $file) || die "Can't open $file: $!";
  18.    print "# $file\n";
  19.    $base = undef;
  20.    while (<FILE>) {
  21.        if (/^<BASE href="([^"]+)">/) {
  22.            $base = URI->new($1);
  23.        } elsif (/^<a href="([^"]*)">.*<\/a>\s*=\s*(\S+)/) {
  24.            die "Missing base at line $." unless $base;        
  25.            $link = $1;
  26.            $exp  = $2;
  27.            $exp = $base if $exp =~ /current/;  # special case test 22
  28.            $abs  = URI->new($link)->abs($base);
  29.            unless ($abs eq $exp) {
  30.               print "$file:$.:  Expected: $exp\n";
  31.               print qq(  abs("$link","$base") ==> "$abs"\n);
  32.               print "not ";
  33.            }
  34.            print "ok $no\n";
  35.            $no++;
  36.        }
  37.    }
  38. }
  39.